/*
 * Copyright (C) 2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/game_state.h"


EXTERN_C_BEGIN


void
game_state_destructor(game_state_t* a_state)
{
  if(a_state != NULL)
    {
      game_state_basic_destructor    (&a_state->basic);
      game_state_selection_destructor(&a_state->selection);
    }
}

void
game_state_init_first_time_only(game_state_t* a_state)
{
  if(a_state != NULL)
    {
      game_state_basic_init_first_time_only    (&a_state->basic);
      game_state_selection_init_first_time_only(&a_state->selection);
    }
}


bool
game_state_is_in_pause(game_state_t* a_state)
{
  return game_state_basic_is_in_pause(&a_state->basic);
}

void
game_state_set_pause(game_state_t* a_state, bool value)
{
  if(a_state != NULL)
    {
      game_state_basic_set_pause(&a_state->basic, value);
    }
}

void
game_state_toogle_pause(game_state_t* a_state)
{
  game_state_basic_toogle_pause(&a_state->basic);
}


unsigned short
game_state_get_update_speed(game_state_t* a_state)
{
  return a_state == NULL ? 0 : a_state->basic.update_speed;
}

bool
game_state_reduce_update_speed(game_state_t* a_state,
			       unsigned short reduction)
{
  return game_state_basic_reduce_update_speed(&a_state->basic, reduction);
}

bool
game_state_decrement_update_speed(game_state_t* a_state)
{
  return game_state_basic_decrement_update_speed(&a_state->basic);
}

bool
game_state_increment_update_speed(game_state_t* a_state)
{
  return game_state_basic_increment_update_speed(&a_state->basic);
}


bool
game_state_has_to_quit(game_state_t* a_state)
{
  return game_state_basic_has_to_quit(&a_state->basic);
}

void
game_state_set_quit(game_state_t* a_state, bool value)
{
  if(a_state != NULL)
    {
      game_state_basic_set_quit(&a_state->basic, value);
    }
}


enum selection_state
game_state_get_selection_state(game_state_t* a_state)
{
  return
    a_state == NULL
    ? SELECTION_STATE_NULL
    : a_state->selection.selection.state;
}

enum selection_2d_type
game_state_get_selection_type(game_state_t* a_state)
{
  return a_state->selection.selection.type;
}


void
game_state_clear_selection(game_state_t* a_state)
{
  game_state_selection_clear(&a_state->selection);
}

void
game_state_starts_rectangle_selection(game_state_t* a_state,
				      unsigned int x,
				      unsigned int y)
{
  game_state_selection_starts_rectangle(&a_state->selection, x, y);
}

void
game_state_moves_rectangle_selection(game_state_t* a_state,
				     unsigned int x,
				     unsigned int y)
{
  game_state_selection_moves_rectangle(&a_state->selection, x, y);
}

void
game_state_ends_rectangle_selection(game_state_t* a_state,
				    unsigned int x,
				    unsigned int y)
{
  game_state_selection_ends_rectangle(&a_state->selection, x, y);
}

void
game_state_move_selected_ships(game_state_t* a_state,
			       unsigned int x,
			       unsigned int y)
{
  game_state_selection_move_ships(&a_state->selection, x, y);
}


EXTERN_C_END
